package com.project.controller;


import com.project.bean.UserBean;
import com.project.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private IUserService services;
    @RequestMapping("login")
    public UserBean login(String username,String password, HttpServletRequest req){
        UserBean user = services.login(username, password);
        req.getSession().setAttribute("loginUser",user);
        return user;
    }
    @RequestMapping("testCode")
    public String checkCode(String userCode,HttpServletRequest req){
        String code = req.getSession().getAttribute("checkCode").toString();
        if (userCode.equalsIgnoreCase(code)){
            return "验证码正确";
        }
        return "验证码不正确";
    }
}
